package com.zy.teacherSide.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zy.teacherSide.entity.TeacherTask;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author 29787
 */
@Mapper
@Component
public interface TeacherTaskDao extends BaseMapper<TeacherTask> {

    /**
     * 根据课程id，教师id，班级id查询当作业
     * @param courseId
     * @param teacherId
     * @param classroomId
     * @return TeacherTask
     */
    @Select("select * from hms_teacher_task where course_id=#{courseId} and teacher_id=#{teacherId} and classroom_id=#{classroomId}")
    TeacherTask getTeacherTask(Integer courseId, Integer teacherId, Integer classroomId);

    /**
     * 根据课程id，教师id，班级id,作业id查询当作业
     * @param courseId
     * @param taskId
     * @param teacherId
     * @param classroomId
     * @return TeacherTask
     */
    @Select("select * from hms_teacher_task where task_id=#{taskId} and course_id=#{courseId} and teacher_id=#{teacherId} and classroom_id=#{classroomId}")
    TeacherTask getTeacherTaskByTaskId(Integer courseId,Integer taskId, Integer teacherId, Integer classroomId);

    /**
     * 根据课程id，班级id查询当作业
     * @param courseId
     * @param classroomId
     * @return  List<TeacherTask>
     */
    @Select("select * from hms_teacher_task where course_id=#{courseId} and classroom_id=#{classroomId}")
    List<TeacherTask> getTaskCourseIdAndClassroomId(Integer courseId, Integer classroomId);

    /**
     * 查询作业信息
     * @param classroomId
     * @param teacherId
     * @param courseId
     * @return List<TeacherTask>
     */
    @Select("select * from hms_teacher_task where classroom_id=#{classroomId} and teacher_id=#{teacherId} and course_id=#{courseId}")
    List<TeacherTask> getTeacherTaskByClassroomIdAndTeacherIdAndCourseId(Integer classroomId, Integer teacherId, Integer courseId);

    /**
     * 根据教师id查询作业信息
     * @param teacherId
     * @return List<TeacherTask>
     */
    @Select("select * from hms_teacher_task where teacher_id=#{teacherId}")
    List<TeacherTask> getTeacherTaskByTeacherId(Integer teacherId);

    /**
     * 根据课程id，教师id，班级id,作业名称查询当作业
     * @param courseId
     * @param taskName
     * @param teacherId
     * @param classroomId
     * @return TeacherTask
     */
    @Select("select * from hms_teacher_task where task_name=#{taskName} and course_id=#{courseId} and teacher_id=#{teacherId} and classroom_id=#{classroomId}")
    TeacherTask getTeacherTaskByCourseIdAndTaskNameAndTeacherIdAndClassroomId(Integer courseId,String taskName, Integer teacherId, Integer classroomId);

}
